package com.zq.recruit.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zq.recruit.dao.dto.CompanyDto;
import com.zq.recruit.dao.entity.Company;
import com.zq.recruit.service.CompanyService;
import com.zq.recruit.mapper.CompanyMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 张乔
* @description 针对表【company】的数据库操作Service实现
* @createDate 2025-03-16 16:38:35
*/
@Service
public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company>
    implements CompanyService{

    @Override
    public PageInfo<Company> findByPage(CompanyDto sysUserDto, Integer pageNum, Integer pageSize) {
        LambdaQueryWrapper<Company> queryWrapper=new LambdaQueryWrapper<>();
//        创建查询条件，用户名模糊查询，创建时间范围查询
        queryWrapper.like(sysUserDto.getCompanyName()!=null&&!StrUtil.isEmpty(sysUserDto.getCompanyName())
                        ,Company::getCompanyName,
                        sysUserDto.getCompanyName())
                .ge(sysUserDto.getCreateTimeBegin()!=null&&!StrUtil.isEmpty(sysUserDto.getCreateTimeBegin())
                        ,Company::getCreatedAt,
                        sysUserDto.getCreateTimeBegin())
                .le(sysUserDto.getCreateTimeEnd()!=null&&!StrUtil.isEmpty(sysUserDto.getCreateTimeEnd())
                        ,Company::getCreatedAt,
                        sysUserDto.getCreateTimeEnd())
                .orderByDesc(Company::getId);

        PageHelper.startPage(pageNum, pageSize);
        List<Company> userList = this.list(queryWrapper);
        PageInfo<Company> page = new PageInfo<>(userList);
        return page;
    }
}




